package top.yiciyuan.web.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBManager
{

	private static String DRIVER;
	public static final String USERNAME;
	public static final String PASSWORD;
	public static final String URL;

	static
	{
		DRIVER = "com.mysql.jdbc.Driver";
		USERNAME = "root";
		PASSWORD = "root";
		URL = "jdbc:mysql://127.0.0.1/joblabxtest";
	}
	
	
	public static Connection getConnection()
	{
		try
		{
			Class.forName(DRIVER);
			return DriverManager.getConnection(URL, USERNAME,PASSWORD);
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	
	public static void close(Connection connection)
	{
		if(connection!=null)
		{
			try
			{
				connection.close();
			} catch (SQLException e)
			{
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
}
